package
{
	import BasicEngine.Dispatcher;
	import BasicEngine.Vector2D;
	import DataStore.BmpDataPool;
	import fl.controls.Button;
	import fl.controls.TextArea;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.errors.IOError;
	import flash.events.ErrorEvent;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.net.URLRequest;
	import flash.text.TextField;
	import flash.utils.ByteArray;
	import flash.utils.Dictionary;
	import flash.utils.getTimer;
	import GameLogic.ENUM;
	import GameLogic.Game;
	import GameLogic.Head;
	import GameLogic.InfoShow;
	import GameLogic.LargeRadar;
	import GameLogic.LuaEditer;
	import GameLogic.PauseBtn;
	import GameLogic.ScanBeam;
	import GameLogic.SpriteBtn;
	import GameLogic.TraceWin;
	import LoadUnit.LoadManager;
	import LoadUnit.UrlLoadTask;
	import Map.MapManager;
	import luaAlchemy.LuaAlchemy;
	import RobotPlayer.AnimationState;
	import RobotPlayer.BaseRobot;
	import RobotPlayer.RobotModule;
	import RobotPlayer.RobotFactory;
	import RobotPlayer.RobotModule;
	import RobotPlayer.RobotPart;
	
	[SWF(width = "760", height = "580", backgroundColor = "0xffffff",frameRate = "60")]
	public class Robotlua extends Sprite
	{
		public function Robotlua()
		{
			Init();
			Game.Star();
			this.addEventListener(Event.ENTER_FRAME, GameEntry);
			
			this.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void
			{
				//Game.Pause = true;
			});
		}
		
		private function GameEntry(e:Event):void
		{
			if (Game.ResourceReady)
			{
			   this.removeEventListener(Event.ENTER_FRAME, GameEntry);
			  
			   var robot:BaseRobot = RobotFactory.CreatRobot(0,0);
			   var part:RobotPart = new RobotPart("rightmissile", 180, 24, -4, 1);
			   part.AddStateData("静止状态", 10, [1008],true,false);
			   RobotFactory.AssemblyPart(robot, "TopModule", 0, 0, part);
			   var part2:RobotPart = new RobotPart("leftmissile", 180, -38, -4, 1);
			   part2.AddStateData("静止状态", 10, [1008],true,false);
			   RobotFactory.AssemblyPart(robot, "TopModule", 0, 0, part2);
			   
			   Game.LuaEdit = new LuaEditer();
			   Game.OpenLuaEditBtn =  new SpriteBtn(BmpDataPool.LuaEditorPool[111]);
			   Game.MenuCanvas.addChild(Game.OpenLuaEditBtn);
			   Game.OpenLuaEditBtn.addEventListener(MouseEvent.CLICK, function(e:Event):void
			   {
				  Game.LuaEdit.visible = true;
			   });
			   Game.OpenLuaEditBtn.x = 555;
			   Game.OpenLuaEditBtn.y = 540;
			   
			   Game.LuaAl.doString("PutMap()");
			   
			   var bottomeBorder:Bitmap = new Bitmap(BmpDataPool.LuaEditorPool[116]);
			   bottomeBorder.y = Game.Height - bottomeBorder.height;
			   Game.MenuCanvas.addChild(bottomeBorder);
			   Game.MenuCanvas.setChildIndex(bottomeBorder, 0);
			   var bottomeBox:Bitmap = new Bitmap(BmpDataPool.LuaEditorPool[119]);
			   bottomeBox.y = Game.Height - bottomeBox.height;
			   bottomeBox.x = -4;
			   Game.MenuCanvas.addChild(bottomeBox);
			   
			   Game.GoAndPlayBtn = new PauseBtn(BmpDataPool.LuaEditorPool[117], BmpDataPool.LuaEditorPool[118], Game.Pause);
			   Game.MenuCanvas.addChild(Game.GoAndPlayBtn);
			   Game.GoAndPlayBtn.x = 10;
			   Game.GoAndPlayBtn.y = 474;
			   
			   Game.InfoShowBtn = new InfoShow(BmpDataPool.LuaEditorPool[121], BmpDataPool.LuaEditorPool[122], Game.Pause);
			   Game.MenuCanvas.addChild(Game.InfoShowBtn);
			   Game.InfoShowBtn.x = 715;
			   Game.InfoShowBtn.y = 540;
			   
			   Game.PrintInfo = new TraceWin();
			   Game.MenuCanvas.addChild(Game.PrintInfo);
			   
			   Game.Robothead = new Head();
			   Game.MenuCanvas.addChild(Game.Robothead);
			   Game.Robothead.x = 74;
			   Game.Robothead.y = 508;
			   Game.MenuCanvas.setChildIndex(Game.Robothead, 0);
			   
			   Game.ShowRadar = new LargeRadar();
			   Game.MenuCanvas.addChild(Game.ShowRadar);
			   Game.ShowRadar.x = 760 - 165;
			   
			   var robotRadarBeam:ScanBeam = new ScanBeam();
			   addChild(robotRadarBeam);
			   robotRadarBeam.x = 200;
			   robotRadarBeam.y = 200;
			   
	 
			}
		}
		
		
		public function Init():void
		{
			Game.Init(this, graphics,760, 580);
			LoadManager.Init();
			MapManager.Init();
		}
	}
}